/*
 * Copyright (C) 2018 Donlon.
 *
 * 2018秋季C语言练习题（2）
 * http://10.105.242.83/contest/424/
 *
 * B. 今年的第几天
 */

#include <stdio.h>

int year_days_common[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int year_days_leap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
	int year, month, day;
	scanf("%d %d %d", &year, &month, &day);
	
	int *year_days = year_days_common;
	
	if (year % 4 == 0 || (year % 100 ==0 && year % 400 != 0)){
		year_days = year_days_leap;
	}
	
	int accu_day=0;
	int i;

	for(i = 0; i < month - 1; i++){
	  accu_day += year_days[i];
	}
	
	printf("%d", accu_day + day);
}